﻿#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include "filter/bilateralFilter.h"

#include <vector>

#include <cstdlib>

using Catch::Matchers::WithinAbs;
using std::vector;

// 测试用灰度图像类型（单通道）
using GrayImage = vector<vector<double>>;
// 测试用彩色图像类型（三通道）
using ColorImage = vector<vector<vector<double>>>;

// 示例：生成测试图像（含噪声）
GrayImage createTestGrayImage(int rows, int cols)
{
    GrayImage img(rows, vector<double>(cols, 128.0));
    // 添加椒盐噪声
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            if (rand() % 100 < 10) { // 10%噪声概率
                img[i][j] = (rand() % 256);
            }
        }
    }
    return img;
}

TEST_CASE("bilateralFilter", "[bilateralFilter]")
{

    GrayImage noisyImg = createTestGrayImage(5, 5);

    // 应用双边滤波
    auto filtered = bilateralFilter(noisyImg, 5, 30.0, 3.0);

    INFO(filtered[0][0]);

    CHECK_THAT(filtered[0][0], WithinAbs(128, 0.01));
}
